
// 基础LZD模块（处理小位宽）
module lzd_core #(
    parameter WIDTH = 24
) (
    input [WIDTH-1:0] data,
    output reg [5:0] count
);
        //直接进行编码
    always @(*) begin
    casez (data)
        24'b1??????????????????????? : count = 0;
        24'b01?????????????????????? : count = 1;
        24'b001????????????????????? : count = 2;
        24'b0001???????????????????? : count = 3;
        24'b00001??????????????????? : count = 4;
        24'b000001?????????????????? : count = 5;
        24'b0000001????????????????? : count = 6;
        24'b00000001???????????????? : count = 7;
        24'b000000001??????????????? : count = 8;
        24'b0000000001?????????????? : count = 9;
        24'b00000000001????????????? : count = 10;
        24'b000000000001???????????? : count = 11;
        24'b0000000000001??????????? : count = 12;
        24'b00000000000001?????????? : count = 13;
        24'b000000000000001????????? : count = 14;
        24'b0000000000000001???????? : count = 15;
        24'b00000000000000001??????? : count = 16;
        24'b000000000000000001?????? : count = 17;
        24'b0000000000000000001????? : count = 18;
        24'b00000000000000000001???? : count = 19;
        24'b000000000000000000001??? : count = 20;
        24'b0000000000000000000001?? : count = 21;
        24'b00000000000000000000001? : count = 22;
        24'b000000000000000000000001 : count = 23;
        24'b000000000000000000000000 : count = 24; // 全零
        default                     : count = 0;  // 理论上不会执行
    endcase
end

endmodule